package leetcode;

import java.util.Arrays;

public class Pro1005 {
    public static void main(String[] args) {

    }

    public int largestSumAfterKNegations(int[] nums, int k) {
        while (k != 0) {
            Arrays.sort(nums);
            nums[nums.length - 1] = -nums[nums.length - 1];
            k--;
        }

        int res = 0;
        for (int num : nums) {
            res += num;
        }
        return res;
    }
}
